package com.huaxin.device.models;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 设备报警配置
 */
@Data
@TableName("device_alarm_configs")
@EqualsAndHashCode(callSuper = true)
public class DeviceAlarmConfig extends BaseModel {

    /**
     * 设备实例ID
     */
    @TableField(value = "device_id")
    @Schema(description = "设备实例ID", example = "d123e456-789a-bcde-f012-3456789abcde")
    private String deviceId;

    /**
     * 使用的模板ID（可为空，表示自定义）
     */
    @TableField(value = "template_id")
    @Schema(description = "使用的模板ID，为空表示自定义", example = "t123e456-789a-bcde-f012-3456789abcde")
    private String templateId;

    /**
     * 覆盖的规则（JSON格式），用于个性化配置
     */
    @TableField(value = "override_rules")
    @Schema(description = "覆盖的规则（JSON格式）", example = "{\"current_threshold\": \"12.5\"}")
    private String overrideRules;

    /**
     * 是否启用报警检测
     * 0=禁用，1=启用
     * 默认启用
     */
    @TableField(value = "is_enabled")
    @Schema(description = "是否启用报警检测", example = "1")
    private Boolean isEnabled = true;

    /**
     * 最后校准时间
     */
    @TableField(value = "last_calibrated_at")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "最后校准时间", example = "2025-08-15 10:30:00")
    private LocalDateTime lastCalibratedAt;

    /**
     * 组织家族ID
     */
    @TableField(value = "family_id")
    @Schema(description = "组织家族ID", example = "f3b2f8e1-4c5d-4e6f-8b2a-1c2d3e4f5a6b")
    private String familyId;
}